package thinkingInJava.generics.wildcard;
// page 403
//: generics/ClassCasting.java
import java.io.*;
import java.util.*;

class Widget{}

public class ClassCasting {
@SuppressWarnings("unchecked")
public void f(String[] args) throws Exception {
  ObjectInputStream in = new ObjectInputStream(
    new FileInputStream(args[0]));
  
  List<Widget> lw = (List<Widget>)in.readObject();
  List<Widget> lw2 = List.class.cast(in.readObject()); // 旧版本上面那句会编译 warming,用此句解决
    // Won't Compile:
//  List<Widget>.class.cast(in.readObject());
}
} ///:~

